// 获取用户数据
import request from '@/api/request'
import type { RegisterData } from '@/types/request/api'
import type { LoginResponse } from '@/types/response/apiResponse'
import { SSEClient } from '@/api/SSEClient'

export const test = async (): Promise<string> => {
  const res = await request.get(`/basic/hello`)
  return res.data
}

/**
 * 注册
 */
export const register = async (data: LoginResponse): Promise<void> => {
    await request.post(`/user/register`, data)
}

/**
 * 登录
 * @param data
 */
export const login = async (data: RegisterData): Promise<LoginResponse> => {
  return await request.post(`/user/login`, data)
}

export const sseTest = () => {
  return new SSEClient('/basic/sse')
}

